package com.songtech.uitest.cases;

import com.songtech.uitest.entities.Indent;
import com.songtech.uitest.resources.IndentResource;
import com.songtech.uitest.util.ConfigLoader;
import com.songtech.uitest.util.RollbackHelper;
import com.songtech.uitest.util.SumUpHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

@ContextConfiguration(locations = {"classpath:spring-test-config.xml"})
public class TestCustomFlow6 extends AbstractTestNGSpringContextTests {

    @Autowired
    private RollbackHelper rollbackHelper;

    @Autowired
    private IndentResource indentResource;

    @Autowired
    private Indent indent;

    @Autowired
    private ConfigLoader configLoader;

    @Autowired
    SumUpHelper sumUpHelper;

    private Logger logger = LoggerFactory.getLogger(TestCustomFlow6.class);

    private final static String xlsFileName = "铁塔简单流程移动发起需求取消.xls";


    @BeforeClass
    public void init() throws Exception {
        configLoader.loadFromFile(xlsFileName);
        indent.setMobileId(indentResource.getMobileID());
        indent.setTowerId(indentResource.getTowerID());
        indent.setFlow(indentResource.getCustomFlow());
        indent.setStepPosition(0);
        rollbackHelper.rollbackCurrentDriverToInit();
    }

    @Test(enabled=true)
    public void testCustomFlow() throws Exception{
        rollbackHelper.run(indent.getFlow());

    }

    @AfterClass
    public void tearDown() {
        logger.info(xlsFileName + "配置流程运行完毕。");
        logger.info("单子当前值：" + indent.getMobileId() +","+ indent.getTowerId() +","+ indent.getCurrentBuildType() +",流程下标位置："+ indent.getStepPosition());

        sumUpHelper.printResult();
        sumUpHelper.clearResult();
    }

}
